package com.jlf.core.engine.persistence.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jlf.core.engine.constant.SchemaConstant;
import com.jlf.core.engine.dao.SchemaDomainDao;
import com.jlf.core.engine.domain.SchemaDomainDO;
import com.jlf.core.engine.persistence.SchemaDomainPersistence;
import com.jlf.core.mp.persistence.impl._SimplePersistenceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.List;


/**
 * 领域数据表定义的持久化服务
 *
 * @author wujr
 * 2023/7/5
 * @version 1.0
 * 【变更历史】
 * [wujr 2023/7/5 1.0 新增]
 */
@Slf4j
@RequiredArgsConstructor
public class SchemaDomainPersistenceImpl extends _SimplePersistenceImpl<SchemaDomainDao, SchemaDomainDO> implements SchemaDomainPersistence {

    @Override
    public List<SchemaDomainDO> loadValid() {
        QueryWrapper<SchemaDomainDO> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(SchemaDomainDO::getStatus, SchemaConstant.Domain.Status.valid);
        return super.list(wrapper);
    }

    @Override
    public SchemaDomainDO getByCode(String domainCode) {
        QueryWrapper<SchemaDomainDO> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(SchemaDomainDO::getDomainCode, domainCode);
        return super.getOne(wrapper);
    }
}
